<!doctype html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>物联网云平台</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link rel="stylesheet" href="/css/font.css">
    <link rel="stylesheet" href="/css/login.css">
    <link rel="stylesheet" href="/css/xadmin.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script src="/lib/layui/layui.js" charset="utf-8"></script>
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <style>
        html{
            height: auto;
        }
    </style>
</head>
<body class="login-bg">

    <div class="login layui-anim layui-anim-up">
        <div class="message" style="font-size: 40px">物联网云平台</div>
        <div id="darkbannerwrap"></div>

        <form action="" class="layui-form">
            <div class="layui-form-item">
                <input type="text" name="username" autocomplete="off" required lay-verify="required" placeholder="用户名"
                       class="layui-input"
                       id="name">
            </div>
            <hr class="hr15">
            <div class="layui-form-item">
                <input name="password" id="pass" autocomplete="off" lay-verify="required" placeholder="密码"
                       type="password"
                       class="layui-input">
            </div>
            <hr class="hr15">
            <div id="tt" class="layui-form-item">
                <div class="layui-form-block">
                    <div id="slider"></div>
                </div>
            </div>
            <hr class="hr15">
            <input value="登录" lay-submit lay-filter="login" style="width:100%;" type="submit">
            <hr class="hr20">
        </form>

    </div>


<script>
    //一般直接写在一个js文件中
    layui.config({
        base: '/dist/sliderVerify/'
    }).use(['sliderVerify', 'form', 'jquery'], function () {
        var sliderVerify = layui.sliderVerify,
            form = layui.form,
            $ = layui.$;
        var slider = sliderVerify.render({
            elem: '#slider'
        });
        //监听提交
        form.on('submit(login)', function (data) {
            //用于表单验证是否已经滑动成功
            // if (slider.isOk()) {
            //      //layer.msg(JSON.stringify(data.field));
            //     //alert('还没滑动滑块');
            // }else{
            //     layer.msg("请先通过滑块验证");
            // }

            // alert(888)
            slider.reset();
            $.ajax({
                type: "post",
                url: "/index/Index/loginVerify",
                sync: false,
                data: {
                    username: data.field.username,
                    password: data.field.password,
                },
                success: function (msg) {
                    if (msg == 'ok') {
                        layer.msg('登录成功！', {
                            icon: 6,
                            time: 600,
                        });
                        // parent.location.reload();
                        setTimeout(function () {
                            location.href = '/index/Index/login';
                        }, 1000);
                        //后台主页
                        // window.location.href = 'http://zengjianqi.com/';
                    } else {
                        layer.alert(msg, {icon: 5})
                    }
                },
                error: function (msg) {
                    layer.alert(msg, {icon: 5})

                }
            });
            return false;


        })

    })

</script>
<script>
    // var input = document.querySelectorAll("input");
    // input[0].addEventListener('mouseenter', function () {
    // 	alert('别摸我');
    // });
    // var slider = document.querySelector('#tt');
    //
    // tt.addEventListener('mouseup',function () {
    // 	alert('你弄疼我了');
    // });
</script>

</body>
</html>